package com.hypo.mapper;

import com.hypo.pojo.Student;
import com.hypo.pojo.StudentQueryParam;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface StudentMapper {
    List<Student> list(StudentQueryParam studentQueryParam);

    @Insert("INSERT INTO student(name,no,gender,phone,id_card,is_college,address,degree,graduation_date,clazz_id,create_time,update_time) values (#{name},#{no},#{gender},#{phone},#{idCard},#{isCollege},#{address},#{degree},#{graduationDate},#{clazzId},#{createTime},#{updateTime})")
    void add(Student student);

    void del(List<Integer> ids);

    @Select("select * from student where id=#{id}")
    Student getById(Integer id);

    @Update("update student set name=#{name},no=#{no},gender=#{gender},phone=#{phone},id_card=#{idCard},is_college=#{isCollege},address=#{address},degree=#{degree},graduation_date=#{graduationDate},clazz_id=#{clazzId},violation_count=#{violationCount},violation_score=#{violationScore},update_time=#{updateTime} where id=#{id}")
    void modify(Student student);


    void handleScore(Integer id, Integer score);

    @MapKey("name")
    List<Map> studentDegreeData();

    @MapKey("clazzList")
    List<Map<String, Object>> studentCountData();

    @Select("select * from student where clazz_id=#{id}")
    Integer queryId(Integer id);
}

